<template>
	<!-- 固件升级 -->
	<view class="p-30">
		<view class="u-text-center m-t-20 f-blod" style="font-size: 20px;">
			100%
		</view>

		<view class="m-t-50">
			<u-button type="primary" @click="handleStart">开始升级</u-button>
		</view>
		<view class="m-t-30">
			<u-button type="primary" @click="handleUpdateMode">进入升级模式</u-button>
		</view>

		<view class="c-grey font-13 m-t-30">
			<text>
				1、确保设备已通电;
				2、确保当前手机没有与设备配对(已配对需要先取消配对);
				3、先点”进入升级模式”按钮，执行成功后设备状态指示灯会快速闪烁;
				4、再点”开始升级”按钮，等待进度条完成，并弹出升级成功提示框;
				5、升级过程中，请勿息屏或切换应用程序;
			</text>
		</view>
		<view class="c-red font-13 m-t-20">
			注:若出现升级过程意外退出，直接点击“开始升级"按钮升级成功即可;
		</view>
	</view>
</template>

<script>
	import {
		getUuid,
		writeBLECharacteristicValue
	} from "../../utils/common";
	const app = getApp();
	export default {
		data() {
			return {

			};
		},
		methods: {
			handleStart() {
				const serviceId = getUuid("5508");
				writeBLECharacteristicValue(serviceId, getUuid("0073"), "", "", (res) => {
					if (res.code === 200) {
						uni.showToast({
							title: "固件已开始升级",
							icon: "none",
						});
					} else {
						uni.showToast({
							title: "开始升级失败",
							icon: "none",
						});
					}
				});
			},
			handleUpdateMode() {
				const serviceId = getUuid("5508");
				writeBLECharacteristicValue(serviceId, getUuid("0072"), "", "设备已进入升级");
			},
		}
	}
</script>

<style lang="scss" scoped>

</style>